<!DOCTYPE html>
<html class="no-js" lang="zxx">

<head>
  <meta charset="utf-8" />
  <meta http-equiv="x-ua-compatible" content="ie=edge" />
  <title>Add Resume - JobGrids Job Portal HTML Template.</title>
  <meta name="description" content="" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <link rel="shortcut icon" type="image/x-icon" href="assets/images/favicon.svg" />
  <!-- Place favicon.ico in the root directory -->

  <!-- Web Font -->
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap"
        rel="stylesheet">

  <!-- ========================= CSS here ========================= -->
  <link rel="stylesheet" href="assets/css/bootstrap.min.css" />
  <link rel="stylesheet" href="assets/css/LineIcons.2.0.css" />
  <link rel="stylesheet" href="assets/css/animate.css" />
  <link rel="stylesheet" href="assets/css/tiny-slider.css" />
  <link rel="stylesheet" href="assets/css/glightbox.min.css" />
  <link rel="stylesheet" href="assets/css/main.css" />
  <!--设置元素隐藏，点击radio注册元素显现-->
  <style>
    .hidden{
        display:none;
    }
  </style>
</head>

<body>
<!--[if lte IE 9]>
<p class="browserupgrade">
  You are using an <strong>outdated</strong> browser. Please
  <a href="https://browsehappy.com/">upgrade your browser</a> to improve
  your experience and security.
</p>
<![endif]-->

<div id="loading-area"></div>

<!-- Start Header Area -->
<header class="header">
  <div class="navbar-area">
    <div class="container">

      <div class="row align-items-center">

        <div class="col-lg-12">
          <nav class="navbar navbar-expand-lg">
            <a class="navbar-brand logo" href="index.html">
              <img class="logo1" src="assets/images/logo/logo.svg" alt="Logo" />
            </a>
            <button class="navbar-toggler" type="button" data-toggle="collapse"
                    data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
                    aria-expanded="false" aria-label="Toggle navigation">
              <span class="toggler-icon"></span>
              <span class="toggler-icon"></span>
              <span class="toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse sub-menu-bar" id="navbarSupportedContent">
              <ul id="nav" class="navbar-nav ml-auto">
                <li class="nav-item">
                  <a  href="index.html">主页</a>
                </li>



                    <li class="nav-item">
                      <a  href="browse-jobs.html">职位搜索</a>
                    </li>



                <li class="nav-item">
                  <a href="blog-grid-sidebar.html">论坛</a></li>


                <li class="nav-item"><a href="contact.html">联系我们 </a> </li>


                <li class="nav-item"><a href="#">其他</a>
                  <ul class="sub-menu">
                    <li><a href="index.html" onclick="logout()">Log Out</a></li>
                    <li><a onclick="checkloginuser()">Personal Info</a></li>
                    <li><a href="about-us.html" onclick="addtoken()">About Us</a></li>
                    <li><a href="job-list.html">Job List</a></li>
                    <li><a href="job-details.html">Job Details</a></li>
                    <li><a href="resume.html">Resume Page</a></li>
                    <li><a href="privacy-policy.html">Privacy Policy</a></li>
                    <li><a href="faq.html">Faq</a></li>
                    <li><a href="pricing.html">Our Pricing</a></li>
                    <li><a href="404.html">404 Error</a></li>
                    <li><a href="mail-success.html">Mail Success</a></li>
                  </ul>
                </li>



                <li class="nav-item"><a href="#"class="active">个人中心</a>
                  <ul class="sub-menu">
                    <li><a href="resume.html">简历查看</a></li>
                    <li><a class="active" href="showseekerinfo.html">个人信息编辑</a></li>
                    <li><a href="add-resume.html">简历编辑</a></li>
                    <li><a href="manage-applications.html">申请进度</a></li>
                    <li><a href="job-alerts.html">消息提醒</a></li>
                    <li><a href="manage-blog.html">管理博客</a></li>
                  </ul>
                </li>
                <li class="nav-item login">

                  <a href="showseekerinfo.html" id="shownameid" >
                  </a>
                  <ul class="sub-menu">
                    <li><a href="index.html" onclick="logout()">退出登录</a></li>
                  </ul>
                </li>
              </ul>
            </div>


          </nav>
          <!-- navbar -->
        </div>
      </div>
      <!-- row -->
    </div>
    <!-- container -->
  </div>
  <!-- navbar area -->
</header>
<!-- End Header Area -->



<!-- Start Add Resume Section -->
<section class="add-resume section">
  <div class="container">
    <div class="row">

      <div class="col-lg-10 offset-lg-1 col-12">
        <div class="add-resume-inner box">
          <div class="post-header align-items-center justify-content-center">
            <h3>个人信息</h3>
            <!--<p>Already have an account? <a href="javacript:" data-toggle="modal" data-target="#login"
                                           class="login"> Click here to login</a></p>-->
          </div>
          <!--基本信息开始-->
          <form class="form-ad" id="seekerinfodetail" method="post" onsubmit="return false">
            <div class="row">
              <div class="col-lg-6 col-12">
                <div class="form-group">
                  <input id="seekerbasicid" name="seekerbid" style="display:none">
                  <label class="control-label">姓名</label>
                  <input required id="seekerdetailname" name="seekername"type="text" class="form-control" placeholder="Name">
                </div>
              </div>
              <div class="col-lg-6 col-12">
                <div class="form-group">
                  <label class="control-label">电话</label>
                  <input required id="seekerdetailphone" name="seekertel"type="text" class="form-control" placeholder="Phone">
                </div>
              </div>
              <div class="col-lg-6 col-12">
                <div class="form-group">
                  <label class="control-label">密码</label>
                  <input required id="seekerdetailpwd" name="seekerpwd" type="text" class="form-control"
                         placeholder="pwd">
                </div>
              </div>
              <div class="col-lg-6 col-12">
                <div class="form-group">
                  <label class="control-label">邮箱</label>
                  <input required id="seekerdetailemail" name="seekeremail"type="email" class="form-control" placeholder="Location, e.g"/>
                </div>
              </div>
              <div class="col-lg-6 col-12">
                <div class="form-group">
                  <label class="control-label">性别</label>
                  <div class="position-relative">
                    <select required name="seekergender" class="form-control" id="seekersigngender">
                      <option value="女">女</option>
                      <option value="男">男</option>
                      <option value="未知">未知</option>
                    </select>
                  </div>
                </div>
              </div>
              <div class="col-lg-6 col-12">
                <div class="form-group">
                  <label for="seekersigndate" class="label">出生日期</label>
                  <div class="position-relative">
                    <input required name="seekerdate" type="date" class="form-control" id="seekersigndate" placeholder="输入出生日期"/>

                  </div>
                </div>
              </div>
            </div>
            <div class="form-group">
              <label for="seekerisedu" class="label">是否为应届生</label>
              <div class="position-relative">
                <select required name="seekerisedu" class="form-control" id="seekerisedu">
                  <option value="是">是</option>
                  <option value="否">否</option>
                </select>
            </div>
            </div>
            <div class="form-group mb-8 button">
              <button class="btn " id="seekermodifybtn" onclick="seekermodify('seekerinfodetail')" >修改基本信息
              </button>
              <button class="btn " id="seekersavebtn" onclick="seekersave('seekerinfodetail')" >保存个人信息
              </button>
            </div>
          </form>
          <!--基本信息（注册必填）结束-->
          <!--受教育经历开始-->
          <h3 class="single-section-title">教育经历</h3>
          <form id="educationexp" class="form-ad" method="post" onsubmit="return false">
            <input id="seekerbasicid2" name="seekerbid" style="display:none">
            <!--<div class="form-group">
              <div class="button-group">
                <div class="action-buttons">
                  <div class="upload-button button">
                    <button class="btn">Choose a cover image</button>
                    <input id="cover_img_file_2" type="file">
                  </div>
                </div>
              </div>
            </div>-->

            <div class="row">
              <div class="col-lg-6 col-12">
                <div class="form-group">
                  <label class="control-label">学历</label>
                  <input name="edulvl" id="seekerdetailedulvl"type="text" class="form-control" placeholder="Degree, e.g. Bachelor">
                </div>
              </div>
              <div class="col-lg-6 col-12">
                <div class="form-group">
                  <label class="control-label">就读学校</label>
                  <input name="school" id="seekerschool"type="text" class="form-control"
                         placeholder="School">
                </div>
              </div>
              <div class="col-lg-6 col-12">
                <div class="form-group">
                  <label class="control-label">就读时间</label>
                  <input name="schoolperiod" id="seekerstuperiod"type="text" class="form-control"
                         placeholder="Study period">
                </div>
              </div>
              <div class="col-lg-6 col-12">
                <div class="form-group">
                  <label class="control-label">所修专业</label>
                  <input name="major" id="seekermajor"type="text" class="form-control"
                         placeholder="Major, e.g Computer Science">
                </div>
              </div>
              <div class="col-lg-6 col-12">
                <div class="form-group">
                  <label class="control-label">当前所在城市</label>
                  <input name="currcity" id="seekercurrcity"type="text" class="form-control"
                         placeholder="City">
                </div>
              </div>
            </div>
            <div class="form-group mb-8 button">
              <button class="btn " id="seekermodifyedubtn" onclick="seekermodify('educationexp')" >修改教育经历
              </button>
              <button class="btn " id="seekersaveedubtn" onclick="seekersave('educationexp')" >保存教育经历
              </button>
            </div>
          </form>
          <!--教育经历结束-->
          <!--工作期望开始-->
          <h3>工作期望</h3>
          <form class="form-ad" id="seekerexpworkform" method="post" onsubmit="return false">
            <input id="seekerbasicid3" name="seekerbid" style="display:none">
            <div class="form-group">
              <label class="control-label">期望的工作类型</label>
              <input type="text" class="form-control" name="expworktype" id="expworktypeid"
                     placeholder="Type of your expjobtype">
            </div>
            <div class="form-group">
              <label class="control-label">期望职位</label>
              <input type="text" class="form-control" name="exppos" id="expposid"
                     placeholder="Type of your expjobtype">
            </div>
            <div class="form-group">
              <label class="control-label">期望工作地点</label>
              <input type="text" class="form-control" name="expworkloc" id="expworklocid"
                     placeholder="location">
            </div>
            <div class="form-group">
              <label class="control-label">期望行业</label>
              <input type="text" class="form-control" name="expworkind" id="expworkindid"
                     placeholder="location">
            </div>
            <div class="form-group">
              <label class="control-label">期望薪资</label>
              <input type="text" class="form-control" name="expworsal" id="expworsalid"
                     placeholder="Salary">
            </div>
            <div class="form-group">
              <label class="control-label">自身优势</label>
              <textarea class="form-control" name="advantage" id="advantageid"
                      rows="3"  placeholder="your advantage"></textarea>
            </div>

            <div class="form-group mb-8 button">
              <button class="btn " id="seekermodifyexpbtn" onclick="seekermodify('seekerexpworkform')" >修改工作期望
              </button>
              <button class="btn " id="seekersaveexpbtn" onclick="seekersave('seekerexpworkform')" >保存工作期望
              </button>
            </div>
          </form>
          <!--结束工作期望-->
          </form>
          <!--上传pdf开始-->
          <h3 class="single-section-title">上传简历</h3>
          <form id="uploadtest" enctype="multipart/form-data" class="form-ad" method="post" onsubmit="return false">
            <div class="row">
              <div class="col-lg-6 col-12">
                <div class="form-group">
                  <input class="hidden" name="uploadseekerid" id="uploadseekerid" readonly/>
                  <label class="control-label" id="pdfchangelabelid"></label>
                  <input type="file" name="file" id="file-uploader" accept=".pdf">
                  <!--提示最大上传大小-->
                  <div id="sizealert"></div>
                  <!--为图像创建一个url,用这个url来显示-->
                  <div id="file-url"></div>
                  <!--显示图像大小-->
                  <div id="feedback"></div>
                </div>
              </div>

            </div>
            <div class="form-group mb-8 button">
              <button class="btn " id="seekermodifypdfbtn" onclick="doupload('uploadtest')" >重新上传简历pdf
              </button>
            </div>
          </form>
          <!--上传pdf结束-->
        </div>
      </div>
    </div>
  </div>
</section>
<!-- End Add Resume Section -->



        <!-- Start Footer Area -->
<footer class="footer">
        <div class="footer-bottom">
            <div class="container">
                <div class="inner">
                    <div class="row">
                        <div class="col-lg-6 col-md-6 col-12">
                            <div class="left">
                                <p><a target="_blank" >软件工程大作业</a></p>
                            </div>
                        </div>
                        <div class="col-lg-6 col-md-6 col-12">
                            <div class="right">
                                <ul>
                                    <li><a href="privacy-policy.html">用户手册</a></li>
                                    <li><a href="#">项目文档</a></li>
                                    <li><a href="https://gitee.com/Yuan-Wi/software-engineering-team/tree/master/">gitee</a></li>
                                    <li><a href="contact.html">联系我们</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- End Footer Middle -->
    </footer>
    <!--/ End Footer Area -->

<!-- ========================= scroll-top ========================= -->
<a href="#" class="scroll-top btn-hover">
  <i class="lni lni-chevron-up"></i>
</a>

<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<!-- ========================= JS here ========================= -->
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/wow.min.js"></script>
<script src="assets/js/tiny-slider.js"></script>
<script src="assets/js/glightbox.min.js"></script>
<script src="https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script src="assets/js/main.js"></script>
<script type="text/javascript">
  //===========退出登录
    function logout(){
   window.localStorage.removeItem('user');
   location.href="http://localhost/static/html/index.html";
  };
  //=============最初需要完成个人信息的展示
  $(document).ready(function(){
  $.ajax({
    url: "http://localhost:8080/seekerdetail",
    type: "GET",
    data: {token : window.localStorage.getItem("user")?window.localStorage.getItem("user"):"notoken"},
    success: function(result){
    if(result.code==200){
     const seeker = result.seeker;
     const upfile = result.upfile;//上传的文件
     //alert("seekerid="+seeker.seekerId);
      document.getElementById("uploadseekerid").value=seeker.seekerId;
     document.getElementById("seekerbasicid").value=seeker.seekerId;
      document.getElementById("seekerbasicid2").value=seeker.seekerId;
      document.getElementById("seekerbasicid3").value=seeker.seekerId;

      document.getElementById("seekerdetailname").value=seeker.seekerName;
      document.getElementById("seekerdetailphone").value=seeker.seekerTel;
      document.getElementById("seekerdetailpwd").value=seeker.seekerPwd;
      document.getElementById("seekerdetailemail").value=seeker.seekerEmail;
      document.getElementById("seekersigngender").value=seeker.seekerGender;
      document.getElementById("seekersigndate").value=seeker.seekerDob;
      document.getElementById("seekerisedu").value=seeker.seekerIsfreshman;
      document.getElementById("seekerdetailedulvl").value = seeker.seekerEdulvl;
      document.getElementById("seekerstuperiod").value = seeker.seekerStudyper;
      document.getElementById("seekerschool").value = seeker.seekerSchname;
      document.getElementById("seekermajor").value = seeker.seekerMaj;
      document.getElementById("seekercurrcity").value = seeker.seekerCity;
      document.getElementById("expworktypeid").value = seeker.seekerExpjobtype;
      document.getElementById("expposid").value = seeker.seekerExppos;
      document.getElementById("expworklocid").value = seeker.seekerExpworkloc;
      document.getElementById("expworkindid").value = seeker.seekerExpind;
      document.getElementById("expworsalid").value = seeker.seekerExpsal;
      document.getElementById("advantageid").value = seeker.seekerAdv;
      //完成简历的显示

          showupfile(upfile);

}
    },
    error:function(){
    alert("返回失败");
    },
    });
    //遍历表单元素为readonly
    $('input').attr('readonly', true);
     $("#seekersigngender").prop('disabled', true);//select
     $("#seekerisedu").prop('disabled', true);//select
     $('#advantageid').prop('readonly', true);//textarea
     //btn
       $("#seekersavebtn").attr("disabled", true);
       $("#seekersaveedubtn").attr("disabled", true);
       $("#seekersaveexpbtn").attr("disabled", true);
  });

  function seekermodify(formid){
    var form = document.getElementById(formid);
    var elements = form.elements;
    //遍历表单去掉表单元素的readonly
    for (var i = 0; i < elements.length; i++) {
      if (elements[i].readOnly) {
        elements[i].readOnly = false;
      }
    }
    if(formid=="seekerexpworkform"){
    $("#seekersaveexpbtn").attr("disabled", false);
    $('#advantageid').prop('readonly', false);//textarea
    }
    else if(formid=="educationexp"){
    $("#seekersaveedubtn").attr("disabled", false);

    }
    else if(formid=="seekerinfodetail"){
    $("#seekersavebtn").attr("disabled", false);
    $("#seekersigngender").prop('disabled', false);//select
    $("#seekerisedu").prop('disabled', false);//select
    }
    else{
    alert("发生错误");
    }
    }
  function seekersave(formid){
  var form = $('#' + formid).serialize();
  //alert("form="+form);

  $.ajax({
      url: "http://localhost:8080/updateseekerdetail",
     type: "POST",
     dataType: "json",
     data: {data:form,btn:formid},
     success: function(result){
     if(result.code==200){
     alert("修改信息成功");
     //readonly并不可修改
     //遍历表单元素为readonly
    //  $('#' + elementId)
    $('input').attr('readonly', true);
    if(formid=="seekerexpworkform"){
    $("#seekersaveexpbtn").attr("disabled", true);
    $('#myTextarea').prop('readonly', true);//textarea
    }
    else if(formid=="educationexp"){
    $("#seekersaveedubtn").attr("disabled", true);
    }
    else if(formid=="seekerinfodetail"){
    $("#seekersavebtn").attr("disabled", true);
    $("#seekersigngender").prop('disabled', true);//select
    $("#seekerisedu").prop('disabled', true);//select
    }

    else{
    alert("发生错误");
    }
     }
     else{
     alert(result.code+"修改失败");
     }
     },
     error: function(){
     alert("修改失败，请稍后重试");
     },
  });
  }
  //===========最初需要完成名字的显示
  $(document).ready(function(){


         /*   alert("新方法");*/
						$.ajax({
    url: "http://localhost:8080/mylogingetusername",
    type: "POST",
    data: {token : window.localStorage.getItem("user")?window.localStorage.getItem("user"):"notoken"},
    success: function(result){
     // alert(result.code);
      if(result.code==200){
      alert(result.msg);
      document.getElementById('shownameid').textContent = "欢迎"+result.msg+"登录";
      }
      else {
        alert(result.code+result.msg);
        }
    },
    error: function(){
    alert("请刷新重试");
    },
  });
				});
   //===========退出登录
    function logout(){
   window.localStorage.removeItem('user');
   location.href="http://localhost/static/html/index.html";
  };

  //====================上传简历pdf
  const fileGridURL = document.getElementById('file-url');
  const fileUploader = document.getElementById('file-uploader');

  function doupload(id){

  var form = document.getElementById(id);
   // alert("uploadform="+id+"form="+form);
  //用表单初始化
  if(confirm("确实要重新上传pdf简历吗?")){
  var formData = new FormData(form);
  //alert("上传的文件"+formData.file);
    $.ajax({
    url: "http://localhost:8080/upload",
    type: "POST",
    data: formData,
    cache: false,
    contentType: false,
    processData: false,
    success: function(data){
      if(data.code==200){
      var upfile = data.upfile;
     showupfile(upfile);
    }
  else{
    alert(data.code+data.msg);
  }
    },
      error: function(data){alert("请刷新重试");},
    });}
    };

  //==============base64转为blog
  // 将 base64 转换为 Blob,控制器得到的base64没有类型mime
function dataURLtoBlob(dataurl) {
    //alert(dataurl);
    var arr = dataurl.split(',');
    //alert(arr.length);
    //alert(arr[0]);arr[0].match(/:(.*?);/)[1]||
    var mime = "application/pdf";
    //alert("mine"+mime);
    var bstr = atob(arr[0]);
     var n = bstr.length;
      var u8arr = new Uint8Array(n);
    while (n--) {
        u8arr[n] = bstr.charCodeAt(n);
    }
    return new Blob([u8arr], { type: mime });
};

  //blog转为file
  function blobToFile(blob, fileName) {
  return new File([blob], fileName);
};
//根据pdffile展示,参数是upfile类
  function showupfile(upfile){
  if(upfile){
  //存在简历
  let blob = dataURLtoBlob(upfile.file);
  let filesize = returnFileSize(upfile.fileSize);
  // 创建URL并下载文件
    let url = URL.createObjectURL(blob);
    let a = document.createElement("a");
    a.href = url;
    a.innerText = "点击在线预览或下载"+upfile.fileName;
    a.target="_blank";//点击后新建页面预览
    fileGridURL.appendChild(a);
    document.getElementById('feedback').innerHTML = "文件大小="+filesize;
    document.getElementById('pdfchangelabelid').innerHTML = "已上传过pdf简历";
    }
    else{
    fileGridURL.innerHTML="";//清空a标签
    document.getElementById('pdfchangelabelid').innerHTML = "请上传pdf简历,最大不能超过3G";
    document.getElementById('feedback').innerHTML = "先上传一份pdf简历吧";
    }
  };
  //===========
  // 文件上传change事件的侦听器
fileUploader.addEventListener('change', (event) => {
  // 读取文件大小
  const file = event.target.files[0];
  const size = file.size;

  let msg = '';

 // 检查文件大小是否大于1MB，并准备一条消息。
  if (size > 3*1024 * 1024*1024) {
      //禁止上传按钮seekermodifypdfbtn
      $("#seekermodifypdfbtn").attr("disabled", true);
      msg = `<span style="color:red;">最大上传3GB. 但您想上传的pdf文件为 ${returnFileSize(size)},请重新选择上传</span>`;
  } else {
    //可以点击上传按钮
    $("#seekermodifypdfbtn").attr("disabled", false);
      msg = `<span style="color:green;">  此${returnFileSize(size)}大小的pdf文件可以上传. </span>`;
  }
  // 向用户显示消息
  document.getElementById('sizealert').innerHTML = msg;
});
  //==========得到文件大小
  function returnFileSize(number) {
  if(number < 1024) {
    return number + 'bytes';
  } else if(number >= 1024 && number < 1048576) {
    return (number/1024).toFixed(2) + 'KB';
  } else if(number >= 1048576) {
    return (number/1048576).toFixed(2) + 'MB';
  }
}
</script>
</body>

</html>
